<template>
  <!-- 已分诊 -->
  <section>
    <div class="form-tool">
      <div></div>
      <div>
        <el-form :inline="true" @submit.native.prevent="getData(-1)">
          <el-form-item>
            <deptSearch v-model="form.deptId"></deptSearch>
          </el-form-item>
          <!-- <el-form-item>
            <el-input v-model="form.medicalCard" placeholder="请输入档案号"></el-input>
          </el-form-item> -->
          <el-form-item>
            <patientSearch v-model="form.patientId"></patientSearch>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" native-type="submit" circle></el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <el-row :gutter="20">
      <el-col v-for="(item,index) in tableList" :key="index" :xs="12" :sm="12" :md="12" :lg="8" :xl="6" class="reserve-user-list">
        <!-- vip-box  -->
        <div :key="index" :class="['card-box',classToName(item.status)]">
          <div class="card-nr">
            <div>
              <img v-if="!item.patientInfo.head" src="@/img/unknown-avatar.png" class="head-img" alt="" style="width:70px;height:70px;">
              <img v-else :src="item.patientInfo.head|imageUrl" class="head-img" alt="" style="width:70px;height:70px;">
            </div>
            <div style="overflow: hidden;">
              <p class="overflow-omit">
                <span style="font-size:18px;">{{item.patientInfo.name}}</span>
                &nbsp;
                <span>（{{item.patientInfo.sex|toSex}}&nbsp;<span v-if="item.patientInfo.age>17">{{item.patientInfo.age}}岁</span><span v-else>{{item.patientInfo.birthday|toTimeContrast}}</span>）</span>
              </p>
              <div class="overflow-omit">登记：{{item.deptName}}，{{item.doctorName}}（{{item.registerName}}）</div>
              <div class="overflow-omit">
                <span>体温：</span>
                <span v-if="item.patientInfo.temperatureType">{{item.patientInfo.temperatureType|changeAssist(temperatureTypeArr)}}</span>
                <span v-else>无</span>
                &nbsp;
                <span v-if="item.patientInfo.temperature">{{item.patientInfo.temperature}}℃</span>
              </div>
              <div class="overflow-omit">
                <span>脉搏：{{item.patientInfo.pulse}}</span>
                &nbsp;&nbsp;&nbsp;
                <span>血压：{{item.patientInfo.diastolicPressure}}/{{item.patientInfo.systolicPressure}}</span>
              </div>
              <div class="overflow-omit">
                登记时间：{{item.gmtCreate | hourDate}}
              </div>
            </div>

          </div>
          <!-- <div class="card-footer">
            <div>{{item.status|changeAssist(yyStatusArray)}}</div>
            <div>{{item.doctorName}}（接诊）</div>
          </div> -->
          <div class="zt-box">{{item.status|changeAssist(yyStatusArray)}} </div>
          <div v-if="item.patientInfo.levelId" class="vip-box">
            <el-tooltip :content="item.patientInfo.levelName" placement="top">
              <img src="@/img/icon-vip.png" alt="">
            </el-tooltip>
          </div>
        </div>
      </el-col>
    </el-row>
    <div v-if="tableList.length == 0" style="color:#999;padding:10px 0;text-align:center;">
      <i class="iconfont iconwushuju" style="font-size:40px;"></i>
      <div>暂无数据</div>
    </div>
    <br>
    <pager v-model="pager" @change-pagenum="getData"></pager>
  </section>
</template>
<script>
export default {
  components: {
    patientSearch: () => import("@/pages/_com/patientSearch.vue"),
    deptSearch: () => import("@/pages/_com/deptSearch.vue")
  },
  filters: {},
  data() {
    return {
      tableList: [],
      //预约
      yyStatusArray: [],
      //体温
      temperatureTypeArr: [],
      pager: { pageSize: 12, pageNum: 1, total: 0 },
      form: {
        patientId: "",
        triageStatus: 2,
        deptId: "",
        medicalCard: ""
      }
    };
  },
  async mounted() {
    let th = this;
    th.showLoading();
    th.yyStatusArray = await th.getCommonConfigByKey("预约状态");
    th.temperatureTypeArr = await th.getCommonConfigByKey("体温类型");
    th.getData();
  },
  methods: {
    getData(type) {
      let th = this;
      if (type == -1) {
        th.pager.pageNum = 1;
        th.pager.total = 0;
      }
      th.showLoading();
      let j = {};
      Object.assign(j, th.form, th.pager);
      th.$api.getRegisterListInfo(j).then(res => {
        if (res.executed) {
          th.tableList = res.dataBody.list;
          th.pager.total = res.dataBody.total;
        }
        th.showLoading(false);
      });
    },
    //判断类名
    classToName(type) {
      switch (type) {
        case 1:
          return "bg-yjz";
          break;
        case 2:
          return "bg-sy";
          break;
        case 3:
          return "bg-hong";
          break;
        case 4:
          return "bg-yqx";
          break;
        case 5:
          return "bg-jzz";
          break;
        default:
          return "bg-dfz";
          break;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
@import "../../_css/reserve.scss";
</style>